package com.campus.business.controller;

import com.campus.common.domain.Product;
import com.campus.common.dto.ResponseDto;
import com.campus.common.dto.order.OrderDto;
import com.campus.common.service.ProductService;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品交易
 * @program: campus
 * @description:
 * @author: ENDING
 * @create: 2024-04-21 01:05
 **/

@Slf4j
@CrossOrigin
@Data
@RestController
@RequestMapping("/product")
public class BusinessController {

    @Autowired
    private ProductService productService;

    @ApiOperation("查询测试接口")
    @GetMapping("/test")
    public String test() {

        return productService.test();
    }

    @ApiOperation("保存商品")
    @PostMapping("/save")
    public ResponseDto<String> saveProduct(@RequestBody Product product) {
        if(productService.save(product)) {
            return new ResponseDto<String>(true, "200", "success", "保存成功");
        }

        return new ResponseDto<String>(true, "1000", "error", "保存失败");
    }
}
